package com.linuxone.tools.client;

import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import com.linuxone.news.NewsThread;
import com.linuxone.news.yahoo.YahooNewsParser;
import com.linuxone.news.yahoo.YahooTodayNews;

public class YahooNewsTester {

	public static void main(String[] args) throws UnsupportedEncodingException {
		System.out.println("Test");
		YahooTodayNews news = new YahooNewsParser().parse();
		System.out.println("news="+news);
//		List<String> sts = news.getDateTime();
//		System.out.println("sts="+sts);
//		for (String st : sts) {
//			System.out.println(st);
//		}
		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		
		int i = 0;
//		Map<String, NewsThread> newsMap = new HashMap<String, NewsThread>();
//		newsMap = news.getAllNewsThread();
		
//		List<NewsThread> myList = new ArrayList<NewsThread>(newsMap.values());
//		Collections.sort(myList, new Comparator<NewsThread>(){
//			@Override
//			public int compare(final NewsThread arg0, final NewsThread arg1) {
//				return arg1.getDate().compareTo(arg0.getDate());
//			}
//		});
//
		
//		for(NewsThread newsThread: news.getAllNewsThreadinList()){
//			System.out.println(newsThread.getDateTime());
//			i++;
//		}
		
//		for(Entry<String, NewsThread> entry: newsMap.entrySet()) {
//			//System.out.println(entry.getKey().toString());
//			System.out.print(((NewsThread) entry.getValue()).getTitle());
//			System.out.println(" - " + ((NewsThread) entry.getValue()).getDateTime());
//			System.out.println(((NewsThread) entry.getValue()).getURL());
////			System.out.println(formatter.format(((NewsThread) entry.getValue()).getDate()));
//			i++;
//		}
		System.out.println();
		System.out.println("total number of row: " + i);
	}

}
